<?php

namespace App\Http\Controllers\Admin;


use Illuminate\Http\Response;
use App\Models\Admin\Seting;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;


class SetingController extends Controller
{
    /**
     * @var Seting
     */
    private $seting;


    /**
     * SetingController constructor.
     */
    public function __construct()
    {
        parent::__construct();
        $this->seting = new Seting();
    }
    /**
     * 编辑系统设置
     *
     * @param  int $id
     *
     * @return Response
     */
    public function website(Request $request)
    {
        $id = 1;
        $apageObj=$this->seting->find($id);
        if (!$apageObj) {
            $errors='内容不存在！';
            return redirect()->route('admin.seting.website')->withErrors(compact('errors'));
        }
        if($request->getMethod()=="POST"){
            $apageObj->site_name = $request->input('site_name');
            $apageObj->keywords = $request->input('keywords');
            $apageObj->icp = $request->input('icp');
            $apageObj->icpLink = $request->input('icpLink');
            $apageObj->desc = $request->input('desc');
            $apageObj->statistics_code = $request->input('statistics_code');
       
            $apageObj->update();

            return redirect()->route('admin.seting.website')->with('success','保存成功!');

        }
//        return view('admin.Apage.edit', ['apage'=>$apageObj]);
         return view('admin.Seting.website', ['apage' => $apageObj]);
    }



}
